#include<cstring>
#include<iostream>
#include<string>
using std::endl;
using std::cout;
using std::string;
class Figure {
public:
    virtual string getName() const = 0;
    virtual double getArea() const = 0;
};

void display(Figure & fig) {
    cout << fig.getName() 
         << "的面积是:" 
         << fig.getArea() << endl ;
}
class Rectangle:public Figure{
public:
    Rectangle(int x,int y):_l(x),_d(y){
    
    }
    string getName() const{
        return "juxing";
    }
     double getArea() const{    
         double x = _l*_d;
         return x;
     }
private:
    int _l;
    int _d;
};
class Circle:public Figure{
public:
    Circle(int r):_r(r){

    } 
    string getName() const{
     return "yuan";
 }
  double getArea() const{
      double x = _r*_r*(3.14);
      return x;
  }

private:
    int _r;

};
class Triangle:public Figure{
private:
    int _h;
    int _w;
    int _d;
public:
    Triangle(int x,int y,int z):_h(x),_w(y),_d(z){
        cout<<"Triangle"<<endl;
    }
 string getName() const{
     return "zhijiaosanjiaox";
 }
  double getArea() const{
      double x = _h*_w*0.5;
      return x;
  }

};
void test() {
    Rectangle r(10, 20);
    Circle c(15);
    Triangle t(3, 4, 5);
    display(r);
    display(c);
    display(t);
}
int main(){
    test();
}
